/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package VIMS;


import java.sql.*;


/**
 *
 * @author shyan
 */
public class Login {

        static private String UserID=null;
        static private String UserPW=null;
          
        
        Login(String InputID,String InputPW)
        {
            UserID=InputID;
            UserPW=InputPW;
        }
        
        public boolean check()
        {
            String tempWord="";
              
            try
            {
                String Query = "SELECT DES_DECRYPT(PW_PASSWORD) FROM PASSWORD WHERE PW_NUMBER IN (SELECT PW_NUMBER FROM EMPLOYEE WHERE EMP_USERNAME = '" +UserID + "')";
                Database ob = new Database();
                ResultSet rset = ob.getResultSet(Query);
                while (rset.next())
                {
                 tempWord = rset.getString(1);
                }              
                if(tempWord.equals(UserPW))
                    return(true);                    
            }
            catch (SQLException e)
            {
                System.out.println("SQL Exception: "+ e.toString());
            }
            return (false);
        }
      
}
